home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-07 | 14.9 KB | 365 lines | [TEXT/McSk] |
- ( Reader application for Pocket Forth 0.6 )
- : RTEST ( -- ) key 13 = 0= IF bye ?terminal drop THEN ;
- page
- ( ******************* W A R N I N G ******************** )
- ( This file creates the ReadMe application. Do NOT run )
- ( this file on a normal copy of Pocket Forth. Instead make )
- ( a SPECIAL copy using ResEdit: )
- ( 1} Open a copy of ReadMe with ResEdit )
- ( 2} Delete the DICT 257 resource from ReadMe )
- ( 3} Open a copy of Pocket Forth with ResEdit )
- ( 4} Copy the DICT 257 resource from Pocket Forth )
- ( 5} Paste the DICT 257 resource into ReadMe )
- ( 6} Save ReadMe with ResEdit )
- ( 7} Quit ResEdit and Open ReadMe )
- ( 8} Type "open" and open Reader )
- ( 9} Press the return key, wait until ReadMe quits. )
- ( 10} Restart ReadMe. )
- ( Type return to continue, anything else to quit. ) rtest
- 0 28 +md ! ( shut off screen echo )
- forget task : task ;
-
- : !FONT ( n -- ) >r ,$ A887 ; ( _TextFont )
- : !FSIZE ( n -- ) >r ,$ A88A ; ( _TextSize )
- : !FACE ( face -- ) >r ,$ A888 ; ( _TextFace )
- : SFONT ( -- ) 0 !font 12 !fsize ; ( 12 point Chicago )
- : CLS ( -- ) 4 +md a>r ,$ A8A3 20 20 !pen ; ( CLear Screen )
-
- ( polygon handle storage )
- 2variable APOLY ( aft button dpoly handle )
- 2variable FPOLY ( fore button poly handle )
-
- : ?PHIT ( h v poly -- flag ) ( true if h,v is in polyBBox )
- 0 >r 2@ dl@ 2 0 d+ 2swap 2>r 2>r ,$ A8AD r> ; ( _PtInRect )
-
- ( create polygons )
- : *POLY ( addr -- ) 0 0 2>r ,$ A8CB 2r> rot 2! ; ( _OpenPoly )
- : *APOLY ( -- ) apoly *poly
- 5 225 !pen 20 210 -to 50 210 -to
- 50 240 -to 20 240 -to 5 225 -to ,$ A8CC ; ( _ClosePgon )
- : *FPOLY ( -- ) fpoly *poly
- 440 225 !pen 425 210 -to 390 210 -to
- 390 240 -to 425 240 -to 440 225 -to ,$ A8CC ; ( _ClosePgon )
-
- ( print polygon )
- : .POLY ( addr -- ) 2@ 2>r ,$ A8C6 ; ( _FramePoly )
- : .AARROW ( -- ) 015 230 !pen ." Prev" apoly .poly ;
- : .FARROW ( -- ) 396 230 !pen ." Next" fpoly .poly ;
- : .ARROWS ( -- ) .aarrow .farrow ;
-
- ( print PICT resources from this file )
- : GETPICT ( id -- dhandle ) 0 0 2>r >r ,$ A9BC 2r> ; ( _GetPict )
- : DPICT ( rect id -- ) GetPict ( -- pictures.handle )
- 2dup 2>r rot a>r ,$ A8F6 ; ( _DrawPicture )
-
- ( rect words )
- : RECT ( compile: -- ) ( run: -- addr ) variable 6 allot ;
- : !RECT ( t l b r rect -- ) >r swap r 4 + 2! swap r> 2! ;
- : @RECT ( rect -- t l b r ) dup 2@ swap rot 4 + 2@ swap ;
- : ROFFSET ( h v rect -- ) a>r 2>r ,$ A8A8 ; ( _OffsetRect )
- : RINSET ( h v rect -- ) a>r 2>r ,$ A8A9 ; ( _InsetRect )
- : ?IN ( h v rect -- flag ) ( true if h,v is in rect at addr )
- 0 >r rot rot 2>r a>r ,$ A8AD r> ; ( _PtInRect )
- : ?EMPTY ( rect -- flag ) 0 >r a>r ,$ A8AE r> ; ( _EmptyRect )
- : RERASE ( rect -- ) a>r ,$ A8A3 ; ( _EraseRect )
-
- ( rects for pictures )
- rect PRECT 15 48 212 405 prect !rect ( title picture rect )
- rect SRECT 192 222 221 370 srect !rect ( signature rect )
-
- : SCR ( -- ) @pen swap drop 16 + 50 swap !pen ; ( special cr )
-
- ( P1 - P? are page drawing routines. They have no stack effect.)
- : P1 cls prect 4000 dpict
- 50 30 !pen ." NEW!" .farrow ;
-
- : P2 cls scr
- ." Its FAST, its FUN and its FREE!" scr scr
- ." Pocket Forth, release 6, is a programming" scr
- ." language for writing Macintosh applications." cr scr
- ." You can take advantage of many new features" scr
- ." in this release such as Apple Events*, Floating" scr
- ." Point, Gestalt** and Drag & Drop* programming." cr scr
- ." I hope you have fun with Pocket Forth, and" scr
- ." maybe even " 2 !face ." use " 0 !face ." it for something."
- scr scr scr ." * System 7 ** System 6.0.7+"
- srect 4001 dpict ( draw signature picture )
- .arrows ;
-
- : P3 cls scr
- ." Code produced by Pocket Forth is compact and fast." cr scr
- ." Since Pocket Forth produces true machine code," scr
- ." you have complete control over your program." cr scr
- ." Examine and run the example programs for" scr
- ." programming suggestions." cr scr
- ." If you have system 7 you can load text files by" scr
- ." dragging a text file icon onto Pocket Forth's icon." cr scr
- ." Older systems can use the menu to “Open” a file."
- .arrows ;
-
- : P4 cls scr
- ." Print and read the Manual and the Glossary." cr scr
- ." The Manual consists of two TeachText documents" scr
- ." suitable for use as a reference to Pocket Forth" scr
- ." for old hats and as a supplement to Brodie's" scr
- 4 !face ." Starting FORTH" 0 !face ." for new Forthers." cr scr
- ." The Glossary, also a TeachText document, is a" scr
- ." list of the words in the Pocket Forth dictionary." scr
- ." Stack effects, pronounciation and usage are shown."
- .arrows ;
-
- : P5 cls scr
- ." Major changes since release 5:" scr scr
- ." • Floating point numbers!" cr scr
- ." Numeric input containing a decimal point is" scr
- ." interpreted as an extended floating point" scr
- ." number. Floating Point numbers are kept on" scr
- ." the stack as ten byte entities." cr scr
- ." SANE is used along with three dozen new" scr
- ." words that manipulate floating point numbers." cr scr scr
- ." ( continued ... )"
- .arrows ;
-
- : P6 cls scr
- ." Floating point continued ..." cr scr
- ." Stack words: " 2 !face
- ." fdrop fdup fswap fpick" scr
- ." fpack froll f>d d>f" cr scr
- 0 !face ." Memory words: " 2 !face ." f@ f! fliteral f," scr
- ." fconstant fvariable" cr scr
- 0 !face ." I/O words: " 2 !face
- ." fnumber sci fix f." cr scr
- 0 !face ." Math words: " 2 !face
- ." fcompare f+ f- f* f/" scr
- ." frem f^ fint fabs fsqrt" scr
- ." fsin fcos ftan fatn" scr
- ." fexp fln" 0 !face
- .arrows ;
-
- : P7 cls scr
- ." • Define and install Apple Events:" cr scr
- ." Apple Events, the standard interface for" scr
- ." inter-application communications, are supported" scr
- ." by Pocket Forth. The four required events are" scr
- ." installed automatically, and you can define" scr
- ." your own Apple Event handlers." cr scr
- ." System 7 (or more) is required to use" scr
- ." Apple Events." scr scr scr
- ." ( continued ... )"
- .arrows ;
-
-
- : P8 cls scr
- ." New words and variables control Apple Events:" cr scr
- 2 !face ." AE: " 0 !face ." and " 2 !face ." AE: " 0 !face
- ." begin and end event definitions" scr
- 2 !face ." ,S " 0 !face
- ." compile (or stack) 4 bytes from ASCII" cr scr
- 2 !face ." +Md " 0 !face ." variables:" scr
- ." 136 Apple Event handler routine" scr
- ." 188 Address of installation list" scr
- ." 190 Error handler routine ("
- 2 !face ." drop " 0 !face ." )" scr
- ." 198 Reply record handle holder" scr
- ." 202 Apple Event record handle" cr scr
- ." See the example program AppleEvents for more."
- .arrows ;
-
- : P9 cls scr
- ." • Use " 2 !face ." ?gestalt " 0 !face
- ." to query the system." cr scr
- ." Using this new system trap, available since" scr
- ." late system 6, you can determine much about" scr
- ." the system software and hardware." scr scr
- ." • A color consious window is created if a" scr
- ." color machine is in use. This has no visual" scr
- ." effect but allows your programs to use color." scr scr
- ." • A new color icon and signature is used."
- .arrows ;
-
- : P10 cls scr
- ." Bug fixes:" cr scr
- ." • The manual has been updated and now" scr
- ." prints with pictures, without errors." cr scr
- ." • " 2 !face ." Back " 0 !face
- ." now compiles correct branches." cr scr
- ." • A 32 bit address error in the update" scr
- ." routine has been fixed." cr scr
- ." • A new word, " 2 !face ." Bye " 0 !face
- ." does not use _ExitToShell."
- .arrows ;
-
- : P11 cls scr
- ." Notes:" cr scr
- ." • Choosing “Save” from the menu confirms your" scr
- ." choice before overwriting the dictionary." cr scr
- ." • " 2 !face ." Grow " 0 !face
- ." is gone, the dictionary is always 32K." cr scr
- ." • 68040's instruction cache must be disabled." cr scr
- ." • " 2 !face ." +Loop " 0 !face
- ." works only with positive arguments." scr scr scr scr
- ." ( continued ... )"
- .arrows ;
-
- : P12 cls scr
- ." Notes, continued ..." cr scr
- ." • The floating point interpreter will" scr
- ." attempt to convert any non-defined" scr
- ." token to a number." cr scr
- ." • A DA version is not included. Bug fixes" scr
- ." are available for version 1.5."
- .arrows ;
-
- : P13 cls scr
- ." Packing list for Pocket Forth, release 6:" cr scr
- ." • The application, Pocket Forth" scr
- ." • The Pocket Forth Manual parts 1 and 2" scr
- ." • The Glossary of Pocket Forth words" scr
- ." • Source code with assembly instructions" cr scr
- ." • Ten example files:" scr
- ." AppleEvents (with HyperCard stack)" scr
- ." Reader create this stand alone application"
- scr scr scr ." ( continued ... )"
- .arrows ;
-
- : P14 cls scr
- ." Examples continued ..." cr scr
- ." TextEdit the guts of a text editor" scr
- ." Sieve the Sieve of Erastothanes" scr
- ." Window&Menu demonstrate them" scr
- ." DataFiles read and write ASCII data files" scr
- ." SANETrig floating point trig. functions" scr
- ." IntegerTrig 16/32 bit math functions" scr
- ." Graphics library of QuickDraw routines" scr
- ." Misc library of utility routines"
- .arrows ;
-
- : P15 cls scr
- ." If you find a bug, need help, or want to talk" scr
- ." about this, write. I'd like to hear from you and" scr
- ." I'll attempt to answer your mail." cr scr
- ." Do not send any money, Pocket Forth is free!" cr scr
- ." Contact me at any of the following addresses:" scr
- ." CompuServe [70566,1474]" scr
- ." AOL cheilman" scr
- ." Email “heilman@pc.maricopa.edu”" scr
- ." U.S. Mail PO box 8345" scr
- ." Phoenix AZ 85066-8345"
- .aarrow ;
-
- variable PWHICH 0 pwhich ! ( page-1 to be drawn )
- 14 constant PNO ( number of pages-1 )
- create PLIST ( ordered list of routines or "pages" )
- ' p1 , ' p2 , ' p3 , ' p4 ,
- ' p5 , ' p6 , ' p7 , ' p8 ,
- ' p9 , ' p10 , ' p11 , ' p12 ,
- ' p13 , ' p14 , ' p15 ,
-
- ( menu, button and event handlers )
- : DOUP pwhich @ 2* plist + @ execute ; ( draw the pwhichth page )
- : DOAFT pwhich @ 1 - 0 max pwhich ! doup ; ( decrement pwhich )
- : DOFOR pwhich @ 1+ pno min pwhich ! doup ; ( increment pwhich )
- : DOFIRST 0 pwhich ! doup ; ( go to first page )
- : DOLAST pno pwhich ! doup ; ( go to last page )
- : DOBUTT ( -- ) ( button handler )
- @mouse apoly ?phit IF apoly 2@ 2>r ,$ A8C9 doaft ELSE
- @mouse fpoly ?phit IF fpoly 2@ 2>r ,$ A8C9 dofor
- THEN THEN ;
-
- ( old style colors )
- : BLACK 33 0 2>r ,$ A862 ; ( black _ForeColor )
- : RED 205 0 2>r ,$ A862 ; ( red _ForeColor )
-
- ( create and destroy pictures )
- : PICTURE ( rect -- dhandle ) ( open a picture )
- 0 0 2>r a>r ,$ A8F3 2r> ; ( _OpenPicture )
- : PCLOSE ,$ A8F4 ; macro ( _ClosePicture )
- : PKILL ( addr -- ) 2@ 2>r ,$ A8F5 ; ( _KillPicture at addr )
- : PDRAW ( rect dhandle -- ) ( draw a picture in rect )
- 2>r a>r ,$ A8F6 ; ( _DrawPicture )
-
- rect BRECT ( the bird's rect )
- rect OBRECT ( old brect )
- 2variable B1PICT ( hold b1's pict handle )
- 2variable B2PICT ( hold b2's pict handle )
- 2variable B3PICT ( hold b3's pict handle )
-
- ( draw the three bird positions )
- : .B1 red 2 0 !pen 6 0 -to 12 6 -to 18 0 -to 22 0 -to black ;
- : .B2 red 0 6 !pen 24 6 -to black ;
- : .B3 red 2 12 !pen 6 12 -to 12 6 -to 18 12 -to 22 12 -to black ;
-
- : BNEW brect picture .b1 pclose b1pict 2!
- brect picture .b2 pclose b2pict 2!
- brect picture .b3 pclose b3pict 2! ;
- : BKILL b1pict pkill b2pict pkill b2pict pkill ;
-
- : B1 brect b1pict 2@ pdraw ;
- : B2 brect b2pict 2@ pdraw ;
- : B3 brect b3pict 2@ pdraw ;
- create .BS ' b1 , ' b2 , ' b3 , ( bird draw array )
- variable BTHIS 0 bthis ! ( offset to the current routine )
-
- : XLATE 3 -1 brect roffset ; ( translate brect )
- : INSET 1 1 brect rinset ; ( shrink brect )
-
- : ANIMATE ( -- ) ( draw the current bird, etc. )
- brect ?empty IF ( if the bird has shrunk to oblivion ... )
- 48 291 60 309 brect !rect THEN ( ... restore its origonal size )
- obrect rerase ( erase the old bird )
- brect @rect obrect !rect ( set the old bird to the current bird )
- 0 -1 obrect rinset ( expand the old birds rect )
- bthis @ ( get the current bird offset )
- dup .bs + @ execute ( execute the address of the draw bird routine )
- 4 < IF ( if its bird 1 or 2 )
- 2 bthis +! xlate ( increment bird offset and move the bird's rect )
- ELSE ( its bird 3 )
- 0 bthis ! xlate inset ( set bird 1, move and shrink bird's rect )
- 2 >r ,$ A889 ( SrcXor _TextMode )
- 50 30 !pen ." NEW! IMPROVED!" ( flip the title )
- THEN ;
-
- variable TLAST 0 tlast ! ( timer )
- 10 constant DELAY
- : TICKS ( -- n ) 364 0 l@ ;
- : ?TIME ( -- flags ) ( true if 1/delay seconds has elapsed )
- ticks tlast @ - abs delay > ;
- : DOIDLE ( do the birdie animation )
- pwhich @ 0= IF ( if its the title page )
- ?time IF ticks tlast ! animate
- THEN THEN ;
-
- : STOP bkill bye ;
-
- ( set menu handlers )
- create GMENU ' dofirst , ' doaft , ' dofor , ' dolast ,
- create FMENU ' stop ,
- create MBAR fmenu , 18 +md @ 2+ @ , gmenu ,
- 2variable GMENUH 0 0 gmenuh 2! ( holder for goMenuHandle )
- ' beep 18 +md @ ( get pointer to menu list )
- 2+ @ ( get pointer to Edit menu from menu list )
- 8 + ! ( set paste handler to beep )
-
- : +MENU ( -- ) ( Turn the new menu on.)
- 0 0 2>r 4 >r ,$ A9BF ( _GetRMenu )
- 2r> 2dup 2>r 0 >r ,$ A935 ( _InsertMenu )
- gmenuh 2! ,$ A937 ; ( _DrawMenuBar )
-
- : START +menu *apoly *fpoly sfont
- 0 0 14 28 brect !rect bnew
- 0 0 0 0 brect !rect
- 0 0 0 0 obrect !rect
- BEGIN key drop AGAIN ; ( event loop )
-
- ( set event/message handlers )
- ' doup 14 +md ! ( set update handler )
- ' dobutt 16 +md ! ( set button handler )
- mbar 18 +md ! ( set the menu handlers )
- ' doidle 20 +md ! ( set idle handler )
- ' stop 22 +md ! ( set quit handler )
- ' start 26 +md ! ( set startup handler )
- ' null 136 +md ! ( disable Apple Events )
- 450 250 8 +md 2! ( set window size )
-
- save bye ( save and quit )
-